extends "../cex___toolman/cex___toolman.gd"
func _info():
	pass

func _connect():
	._connect()
var knighton = 1
var norcnt = 0
func _extInit():
	._extInit()
	chaName = "魔法幼龙"
	lv = 4
	attCoe.atkRan = 4
	attCoe.atk = 20 / 8.5  / 4
	attCoe.maxHp = 1400 / 112.5 / 4
	attAdd.spd += 1
	atkEff = "atk_dang"
	addCdSkill("mfl",3)
	addCdSkill("mfl1",10)
	addSkillTxt("魔法炮弹：对随机3个敌人发出魔法炮弹，造成133%魔法伤害[cd:3秒]")
	addSkillTxt("魔法暴雨：召唤魔法暴雨，对敌方全体造成200%魔法攻击[cd:10秒]")
	addSkillTxt("龙魂击：当龙骑士在场时，普攻3次[击中]后对当前敌人造成龙魂击[对当前敌方造成其以损失生命值10%魔法伤害]")

func _castCdSkill(id):
	._castCdSkill(id)
	if id == "mfl":
		cst("魔法炮弹","000000",position)
		#yield(reTimer(0.1),"timeout")
		var chas = getAllChas(1)
		var waithurt = []
		if chas.size() <= 3:
			for i in range(chas.size()):
				waithurt.append(chas[i])
		else:
			for i in range(3):
				var hcha = chas[sys.rndRan(0,chas.size()-1)]
				chas.remove(chas.find(hcha))
				waithurt.append(hcha)
		for i in range(waithurt.size()):
			yield(reTimer(0.01),"timeout")
			var dmgs = att.mgiAtk * 1.33
			hurtChara(waithurt[i],dmgs,Chara.HurtType.MGI,Chara.AtkType.SKILL)
			
	if id == "mfl1":
		cst("魔法暴雨","000000",position)
		var chas = getAllChas(1)
		for i in chas:
			hurtChara(i,att.atk*2,Chara.HurtType.MGI,Chara.AtkType.SKILL)
			
func _onCharaDel(cha):
	#print(1)
	if cha.id == "cex___Hide_DragonKnight":
		knighton = 0

func _onAtkChara(atkinfo):
	if !atkinfo.isMiss && atkinfo.atkType == Chara.AtkType.NORMAL:
		norcnt += 1
		if knighton && norcnt % 3 == 0:
			cst("龙魂击","000000",position)
			var dmg = atkinfo.hitCha.att.maxHp - atkinfo.hitCha.att.hp
			dmg *= 0.1
			hurtChara(atkinfo.hitCha,dmg,Chara.HurtType.MGI,Chara.AtkType.SKILL)
	._onAtkChara(atkinfo)
